/* name: lodge
 * author: 5ab
 * created at: 2024-06-04
 */
#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define ssz(x) (int((x).size()))

auto chmax = [](auto& x, auto y) { if (x < y) x = y; };
auto chmin = [](auto& x, auto y) { if (y < x) x = y; };

using ll = long long;
const int N = 1e5, NN = 1e3, lgN = 17, EM = 50, M = N + EM, K = 4;

int hd[N], des[M], nxt[M], ord[N], ps[N], st[lgN][N], par[N], deg[N], dep[N], ec = 0, ind = 0;
ll f[N][K + 1];
vector<int> fp[N], tr[N], Tr[N];
bitset<NN> vis[NN];
bool gd[N], use_bitset;

void add(int s, int t)
{
	des[ec] = t;
	nxt[ec] = hd[s];
	hd[s] = ec++;
	deg[t]++;
}

void dfs0(int id, int fa)
{
	ps[ord[id] = ind++] = id, st[0][ord[id]] = fa;
	for (int x : tr[id])
	{
		dep[x] = dep[id] + 1;
		dfs0(x, id);
	}
}

void dfs(int id, int fa)
{
	ps[ord[id] = ind++] = id, st[0][ord[id]] = fa;
	par[id] = fa;
	for (int p = hd[id], dst; p != -1; p = nxt[p])
	{
		dst = des[p];
		if (ord[dst] == -1)
		{
			tr[id].push_back(dst);
			dfs(dst, id);
		}
		else
			fp[id].push_back(dst);
	}
}

void dfs2(int id, int cx)
{
	if (par[id] != -1 && ord[cx] < ord[par[id]])
		par[id] = cx;
	for (int x : tr[id])
		dfs2(x, cx);
}

inline int cmp(int x, int y) {
	return ord[x] < ord[y] ? x : y;
}
void lcainit(int n)
{
	for (int l = 1, c = 2; c < n; c <<= 1, l++)
		for (int i = l; i < n; i++)
			st[l][i] = cmp(st[l - 1][i], st[l - 1][i - c / 2]);
}
inline int lca(int x, int y)
{
	if (x == y)
		return x;
	x = ord[x], y = ord[y];
	if (x > y)
		swap(x, y);
	int d = __lg(y - x);
	return cmp(st[d][y], st[d][x + (1 << d)]);
}

bitset<NN> cn;
int k;
ll tmp[K + 1];
void dfs3(int id, int fa)
{
	int cnt = 0;
	if (use_bitset)
	{
		for (int x = id; x != fa; x = par[x])
		{
			cnt += !cn.test(x);
			// cerr << (cn.test(x) ? -1 : x) << " ";
		}
	}
	else
		cnt = dep[id] - (fa == -1 ? -1 : dep[fa]);
	// cerr << id << " " << fa << " " << cnt << endl;
	fill(f[id], f[id] + k + 1, 0);
	if (!gd[id])
	{
		for (int x : Tr[id])
			dfs3(x, id);
		f[id][0] = 1;
		for (int x : Tr[id])
		{
			fill(tmp, tmp + k + 1, 0);
			for (int i = 0; i <= k; i++)
				for (int j = 0; j <= k - i; j++)
					tmp[i + j] += f[id][i] * f[x][j];
			copy(tmp, tmp + k + 1, f[id]);
		}
	}
	f[id][1] += cnt;
}

signed main()
{
	freopen("lodge.in", "r", stdin);
	freopen("lodge.out", "w", stdout);
	
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	int n, m, qq;
	
	cin >> n >> m >> qq;
	fill(hd, hd + n, -1);
	for (int i = 0, x, y; i < m; i++)
	{
		cin >> x >> y, x--, y--;
		add(x, y);
	}
	fill(ord, ord + n, -1);
	dfs(0, -1);
	
	lcainit(n);
	for (int i = n - 1; i >= 0; i--)
	{
		int x = ps[i];
		for (int y : fp[x])
		{
			int d = lca(x, y);
			if (ord[d] > ord[par[x]])
				d = par[x];
			if (ord[d] < ord[par[y]])
				par[y] = d;
			// cerr << x << " " << y << " " << d << " " << par[y] << endl;
		}
	}
	use_bitset = (n <= NN);
	if (use_bitset)
	{
		queue<int> q;
		for (int i = 0; i < n; i++)
			if (deg[i] == 0)
				q.push(i);
		while (!q.empty())
		{
			int id = q.front(); q.pop();
			vis[id].set(id);
			for (int p = hd[id], dst; p != -1; p = nxt[p])
			{
				dst = des[p];
				vis[dst] |= vis[id];
				if (--deg[dst] == 0)
					q.push(dst);
			}
		}
		for (int i = 0; i < n; i++)
			for (int x = i; x != -1; x = par[x])
				vis[i].reset(x);
	}
	// for (int i = 0; i < n; i++)
	// 	cerr << par[i] << " \n"[i == n - 1];
	
	ind = 0;
	for (int i = 0; i < n; i++)
		tr[i].clear();
	for (int i = 1; i < n; i++)
		tr[par[i]].push_back(i);
	dfs0(0, -1);
	lcainit(n);
	
	int c;
	vector<pair<int, int>> ps;
	while (qq--)
	{
		cin >> k >> c;
		ps.resize(c);
		cn.reset();
		for (int i = 0, x; i < c; i++)
		{
			cin >> x, x--;
			gd[x] = 1;
			ps[i] = { ord[x], x };
			cn |= vis[x];
		}
		sort(all(ps));
		for (int i = 1, j = ssz(ps); i < j; i++)
		{
			int z = lca(ps[i - 1].second, ps[i].second);
			ps.emplace_back(ord[z], z);
		}
		sort(all(ps));
		ps.erase(unique(all(ps)), ps.end());
		for (int i = 1; i < ssz(ps); i++)
		{
			Tr[lca(ps[i - 1].second, ps[i].second)].push_back(ps[i].second);
			// cerr << lca(ps[i - 1].second, ps[i].second) << " ---> " << ps[i].second << endl;
		}
		dfs3(ps[0].second, -1);
		cout << f[ps[0].second][k] << "\n";
		
		for (auto [_, x] : ps)
			Tr[x].clear(), gd[x] = 0;
	}
	
	return 0;
}
// started coding at: 06-04 10:58:56